package com.yanqu.road.server.cmd.activity.xingyoushanshui;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ShanHeFeastProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.xingyou.CrossXingYouActivity;
import com.yanqu.road.server.manager.activity.xingyou.CrossXingYouShanShuiMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;

@Cmd(code = CrossProtocol.C_XING_YOU_SHAN_SHUI_EST_CODE, desc = "测试指令")
public class CrossShanShuiTestCodetCmd extends CrossUnionCommand {

    private int activityId;

    private long userId;

    private String code;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ShanHeFeastProto.CrossFeastTestCodeReqMsg reqMsg = ShanHeFeastProto.CrossFeastTestCodeReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = packet.getPlayerId();
        code = reqMsg.getCode();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossXingYouActivity xingYouActivity = CrossXingYouShanShuiMgr.getActivity(activityId, groupId);
        if (xingYouActivity == null) {
            ret = GameErrorCode.E_SHAN_HE_FEAST_ACTIVITY_NOT_FOUND;
            return;
        }
        xingYouActivity.testCode(userId, code);
    }

    @Override
    public void sendData() {

    }
}
